import QtQuick 2.0
import QtQml.Models 2.1

Rectangle {
    id: root
    width: 320
    height: 410
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    color: "white"

    property string currentStockId: ""
    property string currentStockName: ""

    function initList(content) {
        for (var i = 0; i < content.length; i++ ) {
            listmodel.insert(i,  content[i]);
        }
    }

    ListView {
        id: view
        anchors.fill: parent
        width: parent.width
        clip: true
        keyNavigationWraps: true
        highlightMoveDuration: 0
        focus: true
        snapMode: ListView.SnapToItem

        property int nameSize: 18
        property int dataSize: 20

        model: ListModel {
            id: listmodel
        }


        delegate: Rectangle {
            height: 102
            width: parent.width
            color: "transparent"
            MouseArea {
                anchors.fill: parent;
                onClicked: {
                    view.currentIndex = index;
                }
            }

            Text {
                id: showbpm
                anchors.top: parent.top
                anchors.topMargin: 15
                anchors.left: parent.left
                anchors.leftMargin: 15
                width: 125
                height: 40
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: view.nameSize
                verticalAlignment: Text.AlignVCenter
                text: "心率："
            }

            Text {
                id: showbpmdata
                anchors.top: parent.top
                anchors.topMargin: 15
                anchors.left: showbpm.right
                anchors.leftMargin: 15
                width: 125
                height: 40
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: view.dataSize
                verticalAlignment: Text.AlignVCenter
                text: hrateavg
            }

            Text {
                id: showibi
                anchors.top: parent.top
                anchors.topMargin: 15
                anchors.horizontalCenter: parent.horizontalCenter
                width: 125
                height: 40
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: view.nameSize
                verticalAlignment: Text.AlignVCenter
                text: "心率间隔："
            }
            Text {
                id: showibidata
                anchors.top: parent.top
                anchors.topMargin: 15
                anchors.left: showibi.right
                anchors.leftMargin: 15
                width: 125
                height: 40
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: view.dataSize
                verticalAlignment: Text.AlignVCenter
                text: hrateinterval
            }

            Text {
                id: showtemp
                anchors.top: parent.top
                anchors.topMargin: 15
                anchors.right: showtempdata.left
                width: 125
                height: 40
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: view.nameSize
                verticalAlignment: Text.AlignVCenter
                text: "体温："
            }
            Text {
                id: showtempdata
                anchors.top: parent.top
                anchors.topMargin: 15
                anchors.right: parent.right
                anchors.leftMargin: 15
                width: 125
                height: 40
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: view.dataSize
                verticalAlignment: Text.AlignVCenter
                text: temperature
            }

            Text {
                id: stockNameText
                anchors.bottom: parent.bottom
                //anchors.bottomMargin: 10
                anchors.right: parent.right
                anchors.rightMargin: view.dataSize
                horizontalAlignment: Text.AlignRight
                width: 330
                height: 30
                color: "#000000"
                font.family: "Open Sans"
                font.pixelSize: 12
                font.bold: false
                text: lastSubTime
            }

            Rectangle {
                id: endingLine
                anchors.bottom: parent.bottom
                anchors.left: parent.left
                height: 1
                width: parent.width
                color: "#d7d7d7"
            }
        }

        highlight: Rectangle {
            width: parent.width
            color: "#eeeeee"
        }
    }
    //onVisibleChanged: visible ? root.initList() : null
}
